<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" name="" id="" v-model='con'>
        <button @click='add'>提交</button>
        <div v-for='(item,index) in list'>
            <span>{{item.id}}</span>: <span>{{item.name}}</span><span @click='del(index)'>x</span>
        </div>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        var app=new Vue({
            el:'#app',
            data:{
                con:'',
                list:[
                    {'id':1,'name':'吃饭'},
                    {'id':2,'name':'睡觉'},
                    {'id':3,'name':'打豆豆'}
                ]
            },
            methods:{
                add:function(){
                    var lili=this.list.length
                    this.list.push({id:lili+1,name:this.con})
                },
                del:function(index){
                    this.list.splice(index,1)
                }
            }
        })

    </script>
    
</body>
</html>